﻿<%@ Page Language="C#" MasterPageFile="~/Master.Master" AutoEventWireup="true" CodeBehind="PR_BudgetManage.aspx.cs" Inherits="KPIS.GERP.GHRMS.APP.App_UI.Forms.PR_BudgetManage" %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<%@ Register src="../Controls/user.ascx" tagname="user" tagprefix="uc2" %>

<asp:Content ID="Content1" runat="server" contentplaceholderid="ContentPlaceHolder1">  
<link href="../../Styles/CssClass.css" rel="stylesheet" type="text/css" />
    <telerik:RadScriptBlock runat="server" ID="RadScriptBlock1">
        <script type="text/javascript">
            var sumInput = null;
            var sumInputNet = null;
            var tempValue = 0.0;
            var tempValueNet = 0.0;

            function LoadSumAmount(sender, args) {
                sumInput = sender;
            }
            function LoadSumAmountNet(sender, args) {
                sumInputNet = sender;
            }
            function Blur(txtSumSalary, txtBudgetPercent, txtAmount, txtSumAmount)
            {
                var txtSumSalary = $find(txtSumSalary);
                var txtBudgetPercent = $find(txtBudgetPercent);
                var txtAmount = $find(txtAmount);

                var dSumSalary = 0;
                var dBudgetPercent = 0;
                var dAmount = 0;

                if (txtSumSalary.get_value().toString().length > 0)
                    dSumSalary = txtSumSalary.get_value();
                
                if (txtBudgetPercent.get_value().toString().length > 0)
                    dBudgetPercent = txtBudgetPercent.get_value();

	            dAmount = dSumSalary * (dBudgetPercent / 100);
                txtAmount.set_value(dAmount);
                sumInput.set_value(tempValue + dAmount);
            }
            function Focus(txtSumSalary, txtBudgetPercent, txtAmount, txtSumAmount)
            {
                var lblSumSalary = $find(txtSumSalary);
                var txtBudgetPercent = $find(txtBudgetPercent);
                var txtAmount = $find(txtAmount);
                
                var dAmount = 0;
                
                if (txtAmount.get_value().toString().length > 0)
                    dAmount = txtAmount.get_value();
                    
                tempValue = sumInput.get_value() - dAmount;
            }
            function NetBlur(txtAmountNet, txtSumAmountNet)
            {
                var txtAmountNet = $find(txtAmountNet);
                var dAmountNet = 0;
                
                if (txtAmountNet.get_value().toString().length > 0)
                    dAmountNet = txtAmountNet.get_value();

                sumInputNet.set_value(tempValueNet + dAmountNet);
            }
            function NetFocus(txtAmountNet, txtSumAmountNet)
            {
                var txtAmountNet = $find(txtAmountNet);
                var dAmountNet = 0;
                
                if (txtAmountNet.get_value().toString().length > 0)
                    dAmountNet = txtAmountNet.get_value();
                    
                tempValueNet = sumInputNet.get_value() - dAmountNet;
            }
            function onTextChange(sender) 
            {
                if (sender.get_value() == "") {
                    sender.set_text("");
                }
            } 
        
    </script>
    </telerik:RadScriptBlock>
    <telerik:RadAjaxManager ID="Manager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadGrid1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" />

<link href="../../Styles/CssClass.css" rel="stylesheet" type="text/css" />   
        <table width="30%" cellpadding="0" cellspacing="0" >
        <tr>
           <td valign="top" align="left">               
              <!-- <uc2:user ID="user1" runat="server" /> -->
            <div class="moduleDivSlim700" style="margin:5px 120px 5px 120px;" >
            <div class="moduleDivBottom700">
             <asp:Panel ID="PanelFilter" runat="server" Width="700px" ScrollBars="Auto">
                <table align = "center" width = "700px" >
                    <tr>
                    <td align="right">ประเภทบุคลากร : </td>
                <td align = "left">
                <telerik:RadComboBox ID="cmbEmployeeType" runat="server" 
                    AutoPostBack="True" 
                    CausesValidation="false" 
                    DataTextField="Name" 
                    DataValueField="Sequence" 
                    EmptyMessage="..เลือกประเภทบุคลากร.." Filter="Contains" 
                    OnClientTextChange="onTextChange" 
                    onselectedindexchanged="cbEmployeeType_SelectedIndexChanged" 
                    Width="150px">
                </telerik:RadComboBox>  
            </td>
            <td align="right">ปีงบประมาณ : </td>
            <td align = "left">
                <telerik:RadComboBox 
                    runat="server" 
                    ID="cmbFilterYear" 
                    DataValueField = "Name"
                    DataTextField = "Name"
                    Filter ="Contains"
                    CausesValidation ="false"
                    OnClientTextChange = "onTextChange"
                    Width = "100px" AutoPostBack="True" 
                    onselectedindexchanged="cmbYear_SelectedIndexChanged">
                </telerik:RadComboBox>
            </td>
            <td align="right">การเลื่อนเงินเดือน : </td>
            <td align = "left">
                <asp:RadioButtonList ID="radPromotion" runat="server" AutoPostBack = "true"
                    onselectedindexchanged="radPromotion_SelectedIndexChanged" 
                    RepeatDirection="Horizontal">
                    <asp:ListItem Value="1" Selected = "True">ครั้งที่ 1</asp:ListItem>
                    <asp:ListItem Value="2">ครั้งที่ 2
                </asp:ListItem>
                </asp:RadioButtonList>
            </td>
            </tr>
        </table>
        </asp:Panel>
        </div>
        </div>
        </td>
      </tr>
      <tr>
      <td colspan = "3">
         
        <div class="moduleDivSlim1000x450">
        <div class="moduleDivBottom1000">

        <table width ="980px" align = "center">
        <tr>
            <td align="left" class="tableHeader">
                จัดสรรวงเงินการเลื่อนเงินเดือน</td>
        </tr>
        <tr>
        <td >
        <asp:Panel ID="PanelGrid" 
            runat="server" 
            Width="970px" 
            Height="357px" ScrollBars="Auto" >
        <telerik:RadGrid ID="RadGrid1" runat="server" 
            AllowPaging="True" 
            AllowSorting="true" 
            GridLines="None" 
            PageSize = "100"
            AllowMultiRowEdit = "true"
            OnItemCommand="RadGrid1_ItemCommand"
            OnItemDataBound="RadGrid1_ItemDataBound">
            <MasterTableView ShowFooter="true"
                AutoGenerateColumns="False" 
                CommandItemDisplay="Top"
                CurrentResetPageIndexAction="SetPageIndexToFirst"
                EditMode = "InPlace"
                DataKeyNames="mng_seq" 
                ClientDataKeyNames = "mng_seq"
                Dir="LTR" Frame="Border" 
                TableLayout="Auto">
                <CommandItemTemplate>
                    <table width="100%">
                        <tr>
                            <td>
                                <asp:LinkButton ID="cmdAddNew" runat="server" CausesValidation="False" 
                                    CommandName="InitInsert" Visible = "false" >
                                <img alt="" src="../Images/Buttons/AddRecord.gif"
                                    style="border:0px;vertical-align:middle;" /> เพิ่มรายชื่อบุคลากร</asp:LinkButton>
                                &nbsp;&nbsp;
                            </td>
                            <td align="left">
                                <asp:LinkButton ID="cmdEdit" runat="server" CausesValidation="False" 
                                    CommandName="EditView" >
                                <img alt="" src="../Images/Buttons/Edit.gif" 
                                    style="border:0px;vertical-align:middle;"/> แก้ไขข้อมูล</asp:LinkButton>
                            </td>
                            <td align="left">
                                <asp:LinkButton ID="cmdInsertSelect" runat="server" CausesValidation="False" 
                                    CommandName="InsertSelect" Visible="False">
                                <img alt="" src="../Images/Buttons/saveDisk.gif" 
                                    style="border:0px;vertical-align:middle;"/> บันทึก</asp:LinkButton>
                            </td>
                            <td align="left">
                                <asp:LinkButton ID="cmdCancel" runat="server" CausesValidation="False" 
                                    CommandName="CancelView" Visible="False">
                                <img alt="" src="../Images/Buttons/Cancel.gif" 
                                    style="border:0px;vertical-align:middle;"/> ยกเลิก</asp:LinkButton>
                            </td>
                        </tr>
                    </table>
                </CommandItemTemplate>
                <RowIndicatorColumn>
                    <HeaderStyle Width="20px" />
                </RowIndicatorColumn>
                <Columns>
                <telerik:GridBoundColumn Visible = "false"
                    DataField="mng_seq" 
                    DataType="System.Int32" 
                    HeaderText="mng_seq"
                    ReadOnly="True" 
                    SortExpression="mng_seq" 
                    UniqueName="mng_seq">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn Visible = "false"
                    DataField="sum_salary" 
                    DataType="System.Int32" 
                    HeaderText="sum_salary"
                    ReadOnly="True" 
                    SortExpression="sum_salary" 
                    UniqueName="sum_salary">
                </telerik:GridBoundColumn>
                <telerik:GridTemplateColumn Visible = "false"
                    HeaderText="job_site_seq" 
                    ShowFilterIcon="false"
                    FilterControlWidth="100%"
                    CurrentFilterFunction="Contains"
                    AutoPostBackOnFilter="true"
                    HeaderStyle-HorizontalAlign = "Center"
                    UniqueName="job_site_seq">
                    <ItemTemplate>
                        <asp:Label runat="server" ID="lblJobSiteSeq" 
                            Text='<%# Eval("job_site_seq") %>'>
                        </asp:Label>
                    </ItemTemplate>
                </telerik:GridTemplateColumn>  
                <telerik:GridBoundColumn 
                    DataField="job_site_name" 
                    HeaderText="สำนัก/กอง" 
                    ShowFilterIcon="false"
                    FilterControlWidth="100%"
                    CurrentFilterFunction="Contains"
                    AutoPostBackOnFilter="true"
                    HeaderStyle-HorizontalAlign = "Center"
                    UniqueName="job_site_name">
                </telerik:GridBoundColumn>       
                <telerik:GridTemplateColumn 
                    HeaderText="เงินเดือน ณ " 
                    AllowFiltering = "false"
                    SortExpression="sum_salary" 
                    UniqueName="sum_salary_template"
                    ColumnEditorID="editSumSalaryTemplate"
                    HeaderStyle-HorizontalAlign = "Center"
                    ItemStyle-HorizontalAlign = "Right"
                    EditFormColumnIndex="1"
                    Visible="true">
                    <ItemTemplate>
                        <telerik:RadNumericTextBox runat="server" Visible = "false"
                            ID="txtSumSalary" 
                            Text='<%# Eval("sum_salary") %>'>
                        </telerik:RadNumericTextBox>
                        <asp:Label runat="server" ID="lblSumSalary" 
                            Text='<%# Eval("sum_salary", "{0:N2}") %>'>
                        </asp:Label>
                    </ItemTemplate>

                </telerik:GridTemplateColumn>
                <telerik:GridTemplateColumn 
                    HeaderStyle-HorizontalAlign = "Center"
                    ItemStyle-HorizontalAlign = "Center"
                    UniqueName="Template1" 
                    HeaderText="วงเงินที่จัดสรร(%)">
                    <ItemTemplate>
                        <telerik:RadNumericTextBox ID="txtBudgetPercent" runat="server" 
                            Visible = "false"
                            DbValue='<%# Eval("budget_percent") %>' Type="Percent" 
                            CssClass="NumericTextBox">
                        </telerik:RadNumericTextBox>
                        <asp:Label runat="server" ID="lblBudgetPercent" 
                            Text='<%# Eval("budget_percent") %>'>
                        </asp:Label>
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
                
                <telerik:GridTemplateColumn 
                    HeaderStyle-HorizontalAlign = "Center"
                    ItemStyle-HorizontalAlign = "Center"
                    UniqueName="amount" HeaderText="วงเงินที่จัดสรร(บาท)">
                    <ItemTemplate>
                        <telerik:RadNumericTextBox ID="txtAmount" runat="server" 
                            Visible = "false"
                            DbValue='<%# Eval("amount") %>' CssClass="NumericTextBox">
                        </telerik:RadNumericTextBox>
                        <asp:Label runat="server" ID="lblAmount" 
                            Text='<%# Eval("amount") %>'>
                        </asp:Label>
                    </ItemTemplate>
                    <FooterTemplate>
                        <telerik:RadNumericTextBox ID="txtSumAmount" runat="server" CssClass="NumericTextBox">
                            <ClientEvents OnLoad="LoadSumAmount" />
                        </telerik:RadNumericTextBox>
                    </FooterTemplate>
                </telerik:GridTemplateColumn>
                
                <telerik:GridTemplateColumn 
                    HeaderStyle-HorizontalAlign = "Center"
                    ItemStyle-HorizontalAlign = "Center"
                    UniqueName="amount_net" HeaderText="วงเงินที่จัดสรรจริง">
                    <ItemTemplate>
                        <telerik:RadNumericTextBox ID="txtAmountNet" runat="server" 
                            Visible = "false"
                            DbValue='<%# Eval("amount_net") %>' 
                            CssClass="NumericTextBox">
                        </telerik:RadNumericTextBox>
                         <asp:Label runat="server" ID="lblAmountNet" 
                            Text='<%# Eval("amount_net") %>'>
                        </asp:Label>
                    </ItemTemplate>
                    <FooterTemplate>
                        <telerik:RadNumericTextBox ID="txtSumAmountNet" runat="server" CssClass="NumericTextBox">
                            <ClientEvents OnLoad="LoadSumAmountNet" />
                        </telerik:RadNumericTextBox>
                    </FooterTemplate>
                </telerik:GridTemplateColumn>                
                </Columns>
        </MasterTableView>
        <ClientSettings>
        </ClientSettings>
        <PagerStyle Mode="NextPrevAndNumeric" />
    </telerik:RadGrid>
    </asp:Panel>
    </td>
    </tr>
    
    <tr>
    <td>
    
    </td>
    </tr>
    
    </table>
    </div>
</div>
</td>
</tr>
</table>
</asp:panel>    

</asp:Content>


